package main;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import main.computables.Computable;

public class Factorizator implements Computable<Integer, Integer>{

	private static long countSize;
	
	private SimpleNumbersGen generator = new SimpleNumbersGen(10000);
	
	public long getCount() {
		return countSize;
	}

	public void increment() {
		++countSize;
	}

	public Map<Integer, Integer> factorizate(List<Integer> simpleNumbers, int num) {

		countSize++;

		int[] result = new int[simpleNumbers.size()];

		for (int i = 0; i < simpleNumbers.size(); ++i) {
			while (num % simpleNumbers.get(i) == 0) {
				result[i]++;
				num = num / simpleNumbers.get(i);
			}
		}

		Map<Integer, Integer> map = new HashMap<Integer, Integer>();

		for (int i = 0; i < simpleNumbers.size(); ++i) {
			map.put(simpleNumbers.get(i), result[i]);
		}

		return map;
	}
	
	public int doLong() {
		countSize++;

		Map<Integer, Integer> map = new TreeMap<Integer, Integer>();

		for (int i = 0; i < 10000; ++i) {
			map.put(i, i);
		}

		return map.size();

	}

	@Override
	public Integer compute(Integer arg) throws InterruptedException {

		return arg % doLong();
	}

}
